# 导包
import time
from selenium import webdriver
# 实例化浏览器驱动
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.maximize_window()
# 打开测试网站
driver.get("http://192.168.0.108/home/Index/index.html")
# 把首页导航拖到搜索框
source = driver.find_element(By.XPATH, "//*[@id=\"navitems\"]/li[1]/a")
target = driver.find_element(By.ID, "q")
# 实例化鼠标对象
action = ActionChains(driver)
# 调用鼠标拖动事件方法
action.drag_and_drop(source, target)
# 调用鼠标执行方法
action.perform()
# 等待3S
time.sleep(3)
# 退出浏览器驱动
driver.quit()